package com.sdp.wz.db.wz_info.service.impl;

import com.sdp.wz.db.wz_info.entity.WzInfo;
import com.sdp.wz.db.wz_info.mapper.WzInfoMapper;
import com.sdp.wz.db.wz_info.service.IWzInfoService;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author zsp
 * @since 2024-07-29
 */
@Service
public class WzInfoServiceImpl extends ServiceImpl<WzInfoMapper, WzInfo> implements IWzInfoService {

	@Override
	public List<WzInfo> queryWzInfoByWzNos(List<String> wzNos) {
		LambdaQueryWrapper<WzInfo> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.in(WzInfo::getWzNo, wzNos);
		return list(queryWrapper);
	}

	@Override
	public Map<String, WzInfo> queryWzInfoMapByWzNos(List<String> wzNos) {
		List<WzInfo> wzList = this.queryWzInfoByWzNos(wzNos);
		Map<String,WzInfo> wzInfoMap = new HashMap<>();
		for(WzInfo wz : wzList) {
			wzInfoMap.put(wz.getWzNo(), wz);
		}
		return wzInfoMap;
	}

	@Override
	public WzInfo queryWzInfoByWzNo(String wzNo) {
		LambdaQueryWrapper<WzInfo> queryWrapper = new LambdaQueryWrapper<>();
		queryWrapper.eq(WzInfo::getWzNo, wzNo);
		return getOne(queryWrapper,false);
	}

}
